package org.javarosa.mesh4j.sync.rms;

import java.util.Vector;

import org.mesh4j.sync.adapters.rms.storage.IRmsStorage;
import org.mesh4j.sync.adapters.rms.storage.RmsStorage;
import org.mesh4j.sync.validations.Guard;

public class ConsoleRMSStorage { 

	public final static String DEFAULT_STORAGE_NAME = "M4X_CONSOLE_REPOSITORY";
	
	// MODEL VARIABLES
	private IRmsStorage storage;
	private ConsoleMessageParser parser;
	
	// BUSINESS METHODS
	public ConsoleRMSStorage() {
		this(DEFAULT_STORAGE_NAME);
	}
	
	public ConsoleRMSStorage(String storageName) {
		Guard.argumentNotNullOrEmptyString(storageName, "storageName");
		this.parser = new ConsoleMessageParser();
		this.storage = new RmsStorage(parser, storageName);
	}
	
	public void deleteRecordStorage() {
		this.storage.deleteRecordStorage();		
	}
	
	public void deleteAll() {
		this.storage.deleteAll();		
	}
	
	public void add(String message) {
		this.storage.save(message);
	}

	public Vector getAll(){
		return this.storage.getAll(null, null);
	}
}